;; 仓颉语言语法高亮规则

;; 控制流关键字
"if" @conditional
"else" @conditional
"elif" @conditional
"match" @conditional
"case" @conditional
"where" @conditional
"for" @repeat
"while" @repeat
"break" @repeat
"continue" @repeat
"return" @keyword.return

;; 类型关键字
"struct" @keyword
"class" @keyword
"enum" @keyword
"interface" @keyword
"type" @keyword
"trait" @keyword
"prop" @keyword

;; 可见性修饰符
"public" @keyword
"private" @keyword
"protected" @keyword

;; 变量声明
"const" @keyword
"let" @keyword
"var" @keyword
"mut" @keyword

;; 导入导出
"import" @keyword
"package" @keyword

;; 函数相关
"func" @keyword
"init" @keyword
"deinit" @keyword
"override" @keyword
"open" @keyword
"operator" @keyword

;; 异步相关
( async ) @keyword
( await ) @keyword
( spawn ) @keyword

;; 异常处理
( try ) @keyword
( catch ) @keyword
( finally ) @keyword
( throw ) @keyword
( Exception ) @type
( Error ) @type

;; 字面量
( number_literal ) @number
( string_literal ) @string
( character_literal ) @string
( boolean_literal ) @boolean
( nil ) @constant.builtin

;; 标识符
( identifier ) @variable
( type_identifier ) @type
( function_identifier ) @function

;; 注释
( comment ) @comment

;; 运算符
( operator ) @operator
( binary_operator ) @operator
( unary_operator ) @operator

;; 括号
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket
[ "," ";" ] @punctuation.delimiter

;; 参数和字段
( parameter_declaration ( identifier ) @parameter )
( field_declaration ( identifier ) @field )
( property_declaration ( identifier ) @field )

;; 函数调用
( call_expression ( identifier ) @function.call )
( member_expression ( identifier ) @method )

;; 枚举变体
( enum_variant ( identifier ) @constant )

;; 模式匹配中的变量
( pattern ( identifier ) @variable.parameter )
( pattern ( type_identifier ) @type )

;; 宏
( macro ) @function.macro
( quote ) @function.macro
( unquote ) @function.macro

;; 字符串插值
( interpolated_string ( string_literal ) @string )
( interpolated_string ( expression ) @embedded )

;; 特殊标记
( attribute ) @attribute
( decorator ) @attribute